import request from '../utils/request';

/**
 * 面板
 */

export const fetchDashboardData = () => {
    return request({
        url: '/data',
        method: 'get'
    });
}

/**
 * 消息通知
 */

export const fetchNotificationData = (username) => {
    return request({
        url: '/notification/' + username,
        method: 'get'
    });
}

/**
 * 
 * @returns 公司管理
 */

export const fetchCompanyData = () => {
    return request({
        url: '/company',
        method: 'get'
    });
}

export const fetchCompanyDataById = (id) => {
    return request({
        url: '/company/' + id,
        method: 'get'
    });
}

export const delCompanyDataById = (id) => {
    return request({
        url: '/company/' + id,
        method: 'delete'
    });
}

export const postCompany = (data) => {
    return request({
        url: '/company',
        method: 'post',
        data
    });
}

/**
 * 
 * @returns 财务管理
 */

export const fetchBankLeve1 = (pageNum, pageSize) => {
    return request({
        url: '/bank/level1/page',

        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}

export const saveBankLeve1 = (data) => {
    return request({
        url: '/bank/level1',
        method: 'post',
        data
    });
}

export const delBankLeve1 = (areaName) => {
    return request({
        url: '/bank/level1/' + areaName,
        method: 'delete'
    });
}



export const fetchBankLeve2 = (pageNum, pageSize) => {
    return request({
        url: '/bank/level2/page',
        method: 'get',
        params: {
            pageNum,
            sizeSize
        }
    });
}
export const saveBankLeve2 = (data) => {
    return request({
        url: '/bank/level2',
        method: 'post',
        data
    });
}

export const delBankLeve2 = (id) => {
    return request({
        url: '/bank/level2/' + id,
        method: 'delete'
    });
}

export const fetchLoanData = (page, size) => {
    return request({
        url: '/finance/loan',
        method: 'get',
        params: {
            page,
            size
        }
    });
}

export const saveLoanData = (data) => {
    return request({
        url: '/finance/loan',
        method: 'post',
        data
    });
}

export const delLoanDataById = (id) => {
    return request({
        url: '/finance/loan/' + id,
        method: 'delete'
    });
}

export const fetchFinanceAccountData = (page, size) => {
    return request({
        url: '/finance/account',
        method: 'get',
        params: {
            page,
            size
        }
    });
}

export const saveFinanceAccountFlowData = (data) => {
    return request({
        url: '/finance/account/flow',
        method: 'post',
        data
    });
}

export const delFinanceAccountFlowById = (id) => {
    return request({
        url: '/finance/account/flow/' + id,
        method: 'delete'
    });
}


/**
 * 经营项目
 */
export const fetchBusinessProjectData = (pageNum, pageSize) => {
    return request({
        url: '/business/project/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}

export const saveBusinessProjectData = (data) => {
    return request({
        url: '/business/project',
        method: 'post',
        data
    });
}

export const delBusinessProjectById = (id) => {
    return request({
        url: '/business/project/' + id,
        method: 'delete'
    });
}


//水电费

export const fetchUtilityData = (pageNum, pageSize) => {
    return request({
        url: '/business/utility/bill/page',

        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}

export const saveUtilityData = (data) => {
    return request({
        url: '/business/utility/bill',
        method: 'post',
        data
    });
}

export const delUtilityDataById = (id) => {
    return request({
        url: '/business/utility/bill/' + id,
        method: 'delete'
    });
}

export const saveUtilityRecordData = (data) => {
    return request({
        url: '/business/utility/record',
        method: 'post',
        data
    });
}

export const delUtilityRecordById = (id) => {
    return request({
        url: '/business/utility/record/' + id,
        method: 'delete'
    });
}

export const fetchRevenueData = (pageNum, pageSize) => {
    return request({
        url: '/business/revenue/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}


export const saveRevenueData = (data) => {
    return request({
        url: '/business/revenue',
        method: 'post',
        data
    });
}

export const delRevenueDataById = (id) => {
    return request({
        url: '/business/revenue/' + id,
        method: 'delete'
    });
}


/**
 * 楼栋信息管理
 * @returns 
 */
export const fetchBuildingData = (pageNum, pageSize) => {
    return request({
        url: '/building',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
    }
export const saveBuildingData = (data) => {
    return request({
        url: '/building',   
        method: 'post',
        data

    });
}
export const delBuildingDataById = (id) => {
    return request({
        url: '/building/' + id,
        method: 'delete'
    });
}

export const fetchBuildingRentalData = (pageNum, pageSize) => {
    return request({
        url: '/building/rental',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const saveBuildingRentalData = (data) => {
    return request({
        url: '/building/rental',
        method: 'post',
        data
    });
}
export const delBuildingRentalDataById = (id) => {
    return request({
        url: '/building/rental/' + id,
        method: 'delete'
    });
}

export const fetchBuildingRentalDataByCode = (code) => {
    return request({
        url: '/building/rental/code/' + code,
        method: 'get'  
    });
}

export const fetchBuildingRentalDataById = (id) => {
    return request({
        url: '/building/rental/' + id,
        method: 'get'
    });
}


/**
 * 物业项目
 * @returns 
 */

export const fetchPropertyData = (pageNum, pageSize) => {
    return request({
        url: '/property/project/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const savePropertyData = (data) => {
    return request({
        url: '/property/project',
        method: 'post',
        data
    });
}
export const delPropertyDataById = (id) => {
    return request({
        url: '/property/project/' + id,
        method: 'delete'
    });
}

export const fetchPropertyFinanceData = (pageNum, pageSize) => {
    return request({
        url: '/property/finance/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const savePropertyFinanceData = (data) => {
    return request({
        url: '/property/finance',
        method: 'post',
        data
    });
}
export const delPropertyFinanceDataById = (id) => {
    return request({
        url: '/property/finance/' + id,
        method: 'delete'
    });
}


/**
 * 工程项目
 * @returns 
 */

export const fetchEngineerProjectData = (pageNum, pageSize) => {
    return request({
        url: '/engineer/project/info/page',
        method: 'get',
        params: {
            pageNum,
            sizeSize
        }
    });
}
export const saveEngineerProjectData = (data) => {
    return request({
        url: '/engineer/project/info',
        method: 'post',
        data
    });
}
export const delEngineerProjectDataById = (id) => {
    return request({
        url: '/engineer/project/info/' + id,
        method: 'delete'
    });
}


/**
 * 养老院
 * @returns 
 */
export const fetchElderData = (pageNum, pageSize) => {
    return request({
        url: '/elder/info/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}

export const fetchElderInfoList = () => {
    return request({
        url: '/elder/info/list',
        method: 'get'
    });
}


export const saveElderData = (data) => {
    return request({
        url: '/elder/info',
        method: 'post',
        data
    });
}

export const saveElderDataByIdCard = (data) => {
    return request({
        url: '/elder/info/idCard',
        method: 'post',
        data
    });
}

export const delElderDataById = (id) => {
    return request({
        url: '/elder/info/' + id,
        method: 'delete'
    });
}


export const getElderInfoByIdCard = (id) => {
    return request({
        url: '/elder/info/idCard/' + id,
        method: 'get'
    });
}

export const fetchElderMonthlyFinanceData = (pageNum, pageSize) => {
    return request({
        url: '/elder/monthly/finance/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}

export const getElderMonthlyFinanceById = (id) => {
    return request({
        url: '/elder/monthly/finance/' + id,
        method: 'get'
    });
}

export const saveElderMonthlyFinance = (data) => {
    return request({
        url: '/elder/monthly/finance',
        method: 'post',
        data
    });
}

export const delElderMonthlyFinanceById = (id) => {
    return request({
        url: '/elder/monthly/finance/' + id,
        method: 'delete'
    });
}


/**
 * 微渐派工管理
 * @returns 
 */

export const fetchWeiJianProjectData = (pageNum, pageSize) => {
    return request({
        url: '/weijian/project/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}

export const saveWeiJianProjectData = (data) => {
    return request({
        url: '/weijian/project',
        method: 'post',
        data
    });
}
export const delWeiJianProjectDataById = (id) => {
    return request({
        url: '/weijian/project/' + id,
        method: 'delete'
    });
}

export const fetchWeiJianWorkerData = (pageNum, pageSize) => {
    return request({
        url: '/weijian/worker/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}

export const saveWeiJianWorkerData = (data) => {
    return request({
        url: '/weijian/worker',
        method: 'post',
        data
    });
}
export const delWeiJianWorkerDataById = (id) => {
    return request({
        url: '/weijian/worker/' + id,
        method: 'delete'
    });
}



/**
 * 市政管养
 * @returns 
 */
// 区域一级

export const fetchAreaLeve1 = (pageNum, pageSize) => {
    return request({
        url: '/maintenance/area/level1/page',

        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}

export const saveAreaLeve1 = (data) => {
    return request({
        url: '/maintenance/area/level1',
        method: 'post',
        data
    });
}

export const delAreaLeve1 = (areaName) => {
    return request({
        url: '/maintenance/area/level1/' + areaName,
        method: 'delete'
    });
}


// 区域二级

export const fetchAreaLeve2 = (pageNum, pageSize) => {
    return request({
        url: '/maintenance/area/level2/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const saveAreaLeve2 = (data) => {
    return request({
        url: '/maintenance/area/level2',
        method: 'post',
        data
    });
}

export const delAreaLeve2 = (id) => {
    return request({
        url: '/maintenance/area/level2/' + id,
        method: 'delete'
    });
}

//作业种类管理
export const fetchWorkType = (pageNum, pageSize) => {
    return request({
        url: '/maintenance/work/type/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const saveWorkType = (data) => {
    return request({
        url: '/maintenance/work/type',
        method: 'post',
        data
    });
}
export const delWorkType = (id) => {
    return request({
        url: '/maintenance/work/type/' + id,
        method: 'delete'
    });
}

// 每日作业情况
export const fetchWorkDaily = (pageNum, pageSize) => {
    return request({
        url: '/maintenance/work/daily/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const saveWorkDaily = (data) => {
    return request({
        url: '/maintenance/work/daily',
        method: 'post',
        data
    });
}
export const delWorkDaily = (id) => {
    return request({
        url: '/maintenance/work/daily/' + id,
        method: 'delete'
    });
}


/**
 * 车辆信息管理
 * @returns 
 */

export const fetchVehicleInfo = (pageNum, pageSize) => {
    return request({
        url: '/vehicle/info/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const saveVehicleInfo = (data) => {
    return request({
        url: '/vehicle/info',
        method: 'post',
        data
    });
}
export const delVehicleInfo = (id) => {
    return request({
        url: '/vehicle/info/' + id,
        method: 'delete'
    });
}

//保险管理
export const fetchInsuranceInfo = (pageNum, pageSize) => {
    return request({
        url: '/vehicle/insurance/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const saveInsuranceInfo = (data) => {
    return request({
        url: '/vehicle/insurance',
        method: 'post',
        data
    });
}
export const delInsuranceInfo = (id) => {
    return request({
        url: '/vehicle/insurance/' + id,
        method: 'delete'
    });
}

// 每日里程更新
export const fetchMileageInfo = (pageNum, pageSize) => {
    return request({
        url: '/vehicle/daily/mileage/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const saveMileageInfo = (data) => {
    return request({
        url: '/vehicle/daily/mileage',
        method: 'post',
        data
    });
}
export const delMileageInfo = (id) => {
    return request({
        url: '/vehicle/daily/mileage/' + id,
        method: 'delete'
    });
}

// 加油情况 
export const fetchOilInfo = (pageNum, pageSize) => {
    return request({
        url: '/vehicle/refuel/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const saveOilInfo = (data) => {
    return request({
        url: '/vehicle/refuel',
        method: 'post',
        data
    });
}
export const delOilInfo = (id) => {
    return request({
        url: '/vehicle/refuel/' + id,
        method: 'delete'
    });
}

/**
 * 员工管理
 * @returns 
 */

export const fetchEmployeeInfo = (pageNum, pageSize) => {
    return request({
        url: '/employee/page',
        method: 'get',
        params: {
            pageNum,
            pageSize
        }
    });
}
export const saveEmployeeInfo = (data) => {
    return request({
        url: '/employee',
        method: 'post',
        data
    });
}
export const delEmployeeInfo = (id) => {
    return request({
        url: '/employee/' + id,
        method: 'delete'
    });
}


/**
 * 
 * @returns 
 */
export const fetchUserInfo = (page, size) => {
    return request({
        url: '/user',
        method: 'get',
        params: {
            page,
            size
        }
    });
}
export const saveUserInfo = (data) => {
    return request({
        url: '/user',
        method: 'post',
        data
    });
}
export const delUserInfo = (id) => {
    return request({
        url: '/user/' + id,
        method: 'delete'    
    });
}

export const loginUser = (data) => {
    return request({
        url: '/user/login',
        method: 'post',
        data
    });
}

/**
 * 导入excel
 * @returns 
 */
export const importExcel = (file: File) => {

  console.log('Uploading file:', file);
  const formData = new FormData();
  formData.append('file', file);

  return request({
    url: '/import',
    method: 'post',
    data: formData
  });
}

/////////////////////////////


export const fetchData = () => {
    return request({
        url: './mock/table.json',
        method: 'get'
    });
};

export const fetchUserData = () => {
    return request({
        url: './mock/user.json',
        method: 'get'
    });
};

export const fetchRoleData = () => {
    return request({
        url: './mock/role.json',
        method: 'get'
    });
};
